package com.wl.employee.service;

import com.wl.employee.dao.EmployeeDao;
import com.wl.employee.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeDao employeeDao;

    @Override
    public void addEmployee(Employee employee) {
        employee.setCreateDate(new Date());
        this.employeeDao.addEmployee(employee);
    }

    @Override
    public void editEmployee(Employee employee) {
        employee.setEditDate(new Date());
        this.employeeDao.editEmployee(employee);
    }

    @Override
    public void deleteEmployee(Employee employee) {
        this.employeeDao.deleteEmployee(employee);
    }

    @Override
    public List<Employee> findAll() {
        return this.employeeDao.findAll();
    }

    @Override
    public Employee findById(Integer id) {
        return this.employeeDao.findById(id);
    }
}